package com.tingfeng.ik;

import org.apache.lucene.analysis.Tokenizer;
import org.apache.lucene.analysis.util.TokenizerFactory;
import org.apache.lucene.util.AttributeFactory;

import java.util.Map;

/**
 * IK 工厂类，在 SOlr 配置中使用
 */
public class IKTokenizer4Lucene7Factory extends TokenizerFactory {
    private boolean useSmart = false;

    public IKTokenizer4Lucene7Factory(Map<String, String> map) {
        super(map);
        String useSmartParm = map.get("useSmart");
        if ("true".equalsIgnoreCase(useSmartParm))
            this.useSmart = true;
    }

    @Override
    public Tokenizer create(AttributeFactory factory) {
        return new IKTokenizer4Lucene7(this.useSmart);
    }
}
